home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / ExceptionHandling.lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  29.7 KB  |  846 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        ExceptionHandling.lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    PUT NAMES OF ALL SOFTWARE AUTHORS HERE
  9. #
  10. #    Copyright:    © 1994-1996 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    <1.0.20>    02/05/97    SBR        Updated version resource to 1.2.3.
  19. #    <1.0.19>    02/05/97    SBR        Modified _Match, _MatchBoolean, _SelectBoolean, _Collect.
  20. #    <1.0.18>     6/17/96    MDF        Modified _Launch() task to include inForeground parameter.
  21. #    1.0.17+>     6/17/96    MDF        Modified _Launch() task to include inForeground parameter.
  22. #    <1.0.17>    11/15/95    ML        _Size - switch on pHow, default to 'wh', rename 1st param,
  23. #                                    default to window desc.
  24. #    1.0.16+>    11/15/95    ML        _Size - Revise defaults for pHow
  25. #    <1.0.16>     5/18/95    ML        All _tasks now pass task name and parameters into
  26. #                                    ExceptionHandler() call.
  27. #    1.0.15+>     5/17/95    ML        Changes to support Clouseau merge
  28. #    <1.0.15>     4/12/95    KTA        _MatchBoolean() - Added pExactFlag parameter.
  29. #    <1.0.14>      3/6/95    ML        SpecialHandlers() - Rename gSpecialErrorHandlers to
  30. #                                    gSpecialExceptionHandlers
  31. #    1.0.13+>      3/6/95    ML        rename g
  32. #    <1.0.13>     2/17/95    ML        Replace logstr() calls with Println - don't         want any
  33. #                                    other lib dependencies
  34. #    1.0.12+>     2/17/95    ML        Replace logstr() calls with Println - don't want any other lib
  35. #                                    dependencies
  36. #    <1.0.12>     2/16/95    KTA        ExceptionDispatcher() - Handle case when global
  37. #                                    gExceptionHandlerList is not defined, and when no handler (or
  38. #                                    default) is defined.
  39. #    <1.0.11>      2/6/95    ML        Add Throw parameter to DefaultExceptionHandler();
  40. #    1.0.10+>      2/3/95    ML        Add Throw parameter to DefaultExceptionHandler();
  41. #    <1.0.10>     1/31/95    KTA        Moved some crash handling code to the CrashHandling.Lib
  42. #     <1.0.9>     1/19/95    KTA        Changed several names:  ExceptionHandler() ->
  43. #                                    ExceptionDispatcher(),  gErrorList -> gExceptionHandlerList,
  44. #                                    PopError() -> RemoveExceptionHandler, PushError() ->
  45. #                                    AddExceptionHandler(), DefaultErrorHandler() ->
  46. #                                    DefaultExceptionHandler()
  47. #     <1.0.8>     1/19/95    KTA        Added some of the CrashHandling stuff.
  48. #     <1.0.7>     1/16/95    KTA        Added _DebugStr().
  49. #     <1.0.6>     1/13/95    KTA        Updated Headers
  50. #     <1.0.5>    12/14/94    KTA        Readded marks
  51. #     <1.0.4>     12/7/94    ML        Correct parameter name in _Scroll
  52. #     <1.0.3>     12/1/94    KTA        Changed return values, will work if CommandExceptions is OFF.
  53. #                                    Can check script error after all _Tasks.
  54. #     <1.0.2>    11/30/94    ML        Revised _MatchBoolean for -1105
  55. #     <1.0.1>    11/30/94    ML        Added _Gestalt
  56. #
  57. # ****************************************************************************
  58. #
  59.  
  60. #########################################################################
  61. #                AddExceptionHandler(pTheErrorList)
  62. #========================================================================
  63. #    Description:    pushes error list onto the global error handling stack
  64. #    Parameters:        pExceptionCode - (string, integer, List)
  65. #                            The code to identify the exception
  66. #                    pExceptionHandler - {list}
  67. #                            the Handler in the form: {Task reference,{Parameters} ThrowFlag}
  68. #    Returns:        true if it worked, false if not
  69. #    Examples:        AddExceptionHandler(-1100, {TASK crashRecover,{ "TeachText",1,5 },1});
  70. #    Assumptions:    none
  71. #========================================================================
  72. #    History:
  73. #########################################################################
  74. TASK AddExceptionHandler(pExceptionCode, pExceptionHandler)
  75. begin
  76.     global gExceptionHandlerList;
  77.     returnval := 0;
  78.     if(gExceptionHandlerList)
  79.     begin
  80.         thelist := {pExceptionCode, pExceptionHandler};
  81.         gExceptionHandlerList := insert (thelist, 1, gExceptionHandlerList);
  82.         returnval := 1;
  83.     end;
  84.     return (returnval);
  85. end;
  86.  
  87. #########################################################################
  88. #                RemoveExceptionHandler(pTheError)
  89. #========================================================================
  90. #    Description:    pop first instance of pTheError off the global error handling stack
  91. #    Parameters:        pTheError
  92. #    Returns:        true if it worked, false if not
  93. #    Examples:        RemoveExceptionHandler(-1100);
  94. #    Assumptions:    none
  95. #========================================================================
  96. #    History:
  97. #########################################################################
  98. TASK RemoveExceptionHandler(pTheError)
  99. begin
  100.     global gExceptionHandlerList;
  101.     returnval := 0;
  102.     HandlerData := assoc (pTheError, gExceptionHandlerList);                        # Call assoc to insure it exists and to get data so we can find which element.
  103.     if (HandlerData)
  104.     begin
  105.         theItem := isMember({pTheError,HandlerData }, gExceptionHandlerList);        # Call IsMember to findout which element to remove
  106.         gExceptionHandlerList := remove(theItem,gExceptionHandlerList);
  107.         returnVal := {pTheError,HandlerData };
  108.     end;
  109.     else
  110.         println "!@#$% '{pTheError}' not in error list - could not pop";
  111.     return (returnval);
  112. end;
  113.  
  114.  
  115.  
  116. #########################################################################
  117. #                SpecialHandlers()
  118. #========================================================================
  119. #    Description:    
  120. #    Parameters:        
  121. #    Returns:        true if it worked, false if not
  122. #    Examples:        SpecialHandlers(-);
  123. #    Assumptions:    none
  124. #========================================================================
  125. #    History:
  126. #    ML    3/6/95    Rename gSpecialErrorHandlers to gSpecialExceptionHandlers
  127. #########################################################################
  128. TASK SpecialHandlers(pErrorCode, pHanderList)
  129. begin
  130.     returnVal := 0;
  131.     if(global gSpecialExceptionHandlers)    # List of Special Error handlers which handle groups of errors
  132.     begin
  133.         ##### ALL
  134.         allErrorsList := assoc('all',gSpecialExceptionHandlers);
  135.         if(allErrorsList)
  136.             returnVal := call(allErrorsList[1],pErrorCode, allErrorsList[2]);
  137.         else
  138.         begin
  139.             throwFlag := pHanderList[3];
  140.             ##### ALLNONTHROWN
  141.             if not (throwFlag)            # If ThrowFlag not set
  142.             begin
  143.                 allNonThrownErrorsList := assoc('allNonThrown',gSpecialExceptionHandlers);
  144.                 if(allNonThrownErrorsList)
  145.                     returnVal := call(allNonThrownErrorsList[1],pErrorCode, allNonThrownErrorsList[2]);
  146.             end;
  147.             else # ALLTHROWN - throwFlag set
  148.             begin
  149.                 allThrownErrorsList := assoc('allThrown',gSpecialExceptionHandlers);
  150.                 if(allThrownErrorsList)
  151.                     returnVal := call(allThrownErrorsList[1],pErrorCode, allThrownErrorsList[2]);
  152.             end;
  153.         end;
  154.     end;
  155.     return(returnVal);
  156. end;
  157.  
  158. #########################################################################
  159. #                ExceptionDispatcher(pErrorCode, pHandleTheError)
  160. #========================================================================
  161. #    Description:    A mechanism for handling errors
  162. #    Parameters:        pErrorCode:    The error code
  163. #    Returns:        result of error handler TASK call, or throw if fatal
  164. #    Examples:        ExceptionDispatcher(-1100)
  165. #    Assumptions:    VU 2.1, also needs a list of error codes/handlers defined in
  166. #                    global gExceptionHandlerList in the form:
  167. #                            {     {
  168. #                                ErrCode,                 # Error Code
  169. #                                    {
  170. #                                    Handler,             # TASK reference
  171. #                                    {Parameters},        # List of Parameters
  172. #                                    ThrowFlag            # Flag indicating whether you want errors 
  173. #                                    }                    #  with this code to be thrown
  174. #                                }, …
  175. #                            };
  176. #========================================================================
  177. #    History:
  178. # KTA    2/16/95    Handle case when global gExceptionHandlerList is not defined
  179. #                and when no handler (or default) is defined.
  180. # ML    2/17/94    Replace logstr() calls with Println
  181. #########################################################################
  182. TASK ExceptionDispatcher(pErrorCode, pHandleTheError:= 0, pErrorContext := {})
  183. begin
  184.     global gExceptionHandlerList, gDebugExceptionHandling;               
  185.     returnval := 0;
  186.     if gDebugExceptionHandling
  187.         println "∑ Entering ExceptionDispatcher - Error: {pErrorCode}, task: {pErrorContext[1]} params: {pErrorContext[2]}";
  188.     if global gExceptionDispatcherHook
  189.         call (gExceptionDispatcherHook, pErrorCode, pErrorContext);
  190.     if(gExceptionHandlerList)
  191.     begin
  192.         HandlerList := assoc(pErrorCode,gExceptionHandlerList);
  193.         if not(HandlerList)        # If no handler defined for error id - Check for a default handler        
  194.             HandlerList := assoc('default',gExceptionHandlerList);                #  assign default handler
  195.         if not(HandlerList)        # If no default handler then assign one.
  196.         begin
  197.             Println "!@#$% - WARNING - there was no handler defined for this error and there was no default, assigning a default handler";
  198.             HandlerList := {task DefaultExceptionHandler, {1},0};                 #  assign default handler
  199.         end;
  200.         if not(SpecialHandlers(pErrorCode, HandlerList))        # If a SpecialHandler to handle 
  201.         begin                                                    #  the error is not installed
  202.             if ((HandlerList[3]) and not(pHandleTheError))        # Is ThrowFlag Set
  203.                 Throw(pErrorCode);
  204.             else
  205.             begin                                                # ThrowFlag not set
  206.                 switch pErrorCode
  207.                 begin
  208.                     case 'placeholder':
  209.                         println "placeholder in ExceptionDispatcher";
  210.                     default:
  211.                         returnval := call(HandlerList[1],pErrorCode, HandlerList[2]);
  212.                 end; 
  213.             end; 
  214.         end; 
  215.     end;
  216.     else        # No gExceptionHandlerList defined
  217.     begin
  218.         Println "!@#$% - WARNING - the global gExceptionHandlerList is not defined, assigning a default handler";
  219.         returnval := DefaultExceptionHandler(pErrorCode, {1});
  220.     end;
  221.     return (returnval);
  222. end;
  223.  
  224.  
  225. #########################################################################
  226. #                DefaultExceptionHandler(pErrID, pParamList)
  227. #========================================================================
  228. #    Description:    Simple exception Handler that just prints the error code
  229. #                    and the list of parameters.  We may add more as soon as 
  230. #                    we figure out what functionality to add.
  231. #    Parameters:        pErrID: the error code
  232. #                    pParamList:    list of parameters
  233. #    Returns:        1
  234. #    Examples:        DefaultExceptionHandler({"param1", 2, {'param3'}})
  235. #    Assumptions:    VU 2.1
  236. #========================================================================
  237. #    History:
  238. #    ML    2/3/95    Add second element in pParamList for throw
  239. #########################################################################
  240. TASK DefaultExceptionHandler(pErrID, pParamList)
  241. begin
  242.     if(pParamList[1])
  243.         println "DefaultExceptionHandler() : error - {pErrID}/ Params - {pParamList}";
  244.     if not(isUndefined(pParamList[2]))    # Will allow us to exit old style quicklook scripts
  245.         Throw pParamList[2];
  246.     return(1);
  247. end;
  248.  
  249. #########################################################################
  250. ## 
  251. #########################################################################
  252.  
  253. #########################################################################
  254. #                _Match(pDescriptor, pExactFlag)
  255. #========================================================================
  256. #    Description:    Error checking prototype for descriptor matching
  257. #    Parameters:        pTheDesc:    the descriptor to match, always looks for exact
  258. #                                (don't include '!')
  259. #    Returns:        [] - couldn't match
  260. #                    descriptor - successful match
  261. #    Examples:        _Match([window o:1]);
  262. #    Assumptions:    VU 2.1
  263. #========================================================================
  264. #    History:
  265. # SBR    02/05/97    Return [] for match fail instead of 0.
  266. #########################################################################
  267. TASK _Match(pDescriptor := [target], pExactFlag := 0, pNotErrors := {-1105})
  268. begin
  269.     try 
  270.     begin
  271.         if(pExactFlag)
  272.             return(match pDescriptor!);
  273.         else
  274.             return(match pDescriptor);
  275.     end;
  276.     catch theError
  277.     begin
  278.         if (theError = -1105) AND isMember(-1105, pNotErrors)
  279.             # SBR Fixed 09/20/96
  280.             #return theMatch;                # -1105 = simple match failure
  281.             return [];                        # -1105 = simple match failure
  282.         else
  283.             ExceptionDispatcher(theError,,{"_Match", {pDescriptor, pExactFlag}});
  284.  
  285.         # SBR Fixed 09/20/96
  286.         #return(0);
  287.         return [];
  288.     end;
  289. end;
  290.  
  291. #########################################################################
  292. #                _MatchBoolean(pTheDesc)
  293. #========================================================================
  294. #    Description:    Error checking prototype for descriptor matching
  295. #    Parameters:        pTheDesc:    the descriptor to match, always looks for exact
  296. #                                (don't include '!')
  297. #    Returns:        false - couldn't match
  298. #                    true - successful match
  299. #    Examples:        _MatchBoolean([window o:1]);
  300. #    Assumptions:    VU 2.1
  301. #========================================================================
  302. #    History:
  303. # ML    11/30/94    Case out -1105
  304. # KTA    04/12/95    Added pExactFlag parameter
  305. # SBR    01/30/97    Return true or false, not 1 or 0
  306. #########################################################################
  307. TASK _MatchBoolean(pDescriptor := [target], pExactFlag := true)
  308. begin
  309.     try 
  310.     begin
  311.         if(pExactFlag)
  312.             match pDescriptor!;
  313.         else
  314.             match pDescriptor;
  315.             
  316.         return(not ScriptError());
  317.     end;
  318.     catch theError
  319.     begin
  320.         if not(theError = -1105)
  321.             ExceptionDispatcher(theError,,{"_MatchBoolean", {pDescriptor, pExactFlag}});
  322.  
  323.         return false;
  324.     end;
  325. end;
  326.  
  327. #########################################################################
  328. #                _Select(pTheDesc)
  329. #========================================================================
  330. #    Description:    Error checking prototype for descriptor selecting
  331. #    Parameters:        pTheDesc:    the descriptor to select
  332. #    Returns:        0 - couldn't match
  333. #                    1 - successful match
  334. #    Examples:        _Select([window o:1]);
  335. #    Assumptions:    VU 2.1
  336. #========================================================================
  337. #    History:
  338. #########################################################################
  339. TASK _Select(pDescriptor := [target], pExactFlag := 0)
  340. begin
  341.     try 
  342.     begin
  343.         if(pExactFlag)
  344.             select pDescriptor!;
  345.         else
  346.             select pDescriptor;
  347.     end;
  348.     catch theError
  349.         ExceptionDispatcher(theError,,{"_Select", {pDescriptor, pExactFlag}});
  350. end;
  351.  
  352. #########################################################################
  353. #                _SelectBoolean(pTheDesc)
  354. #========================================================================
  355. #    Description:    Error checking prototype for descriptor matching
  356. #    Parameters:        pTheDesc:    the descriptor to select, always looks for exact
  357. #                                (don't include '!')
  358. #    Returns:        false - couldn't select
  359. #                    true - successful select
  360. #    Examples:        _SelectBoolean([menuitem t:"Open" m: [menu t:"File"]]);
  361. #    Assumptions:    VU 2.1
  362. #========================================================================
  363. #    History:
  364. # SBR    02/05/97    Return false for fail instead of 0.
  365. #########################################################################
  366. TASK _SelectBoolean(pDescriptor := [target], pExactFlag := true)
  367. begin
  368.     try 
  369.     begin
  370.         if(pExactFlag)
  371.             select pDescriptor!;
  372.         else
  373.             select pDescriptor;
  374.         return(not ScriptError());
  375.     end;
  376.     catch theError
  377.     begin
  378.         if not ((theError = -1105) or (theError = -1106))
  379.             ExceptionDispatcher(theError,,{"_SelectBoolean", {pDescriptor, pExactFlag}});
  380.         return false;
  381.     end;
  382. end;
  383.  
  384. #########################################################################
  385. #                _Drag(pTheDesc)
  386. #========================================================================
  387. #    Description:    Error checking prototype for descriptor selecting
  388. #    Parameters:        pTheDesc:    the descriptor to select
  389. #    Returns:        0 - couldn't match
  390. #                    1 - successful match
  391. #    Examples:        _Drag([window o:1]);
  392. #    Assumptions:    VU 2.1
  393. #========================================================================
  394. #    History:
  395. #########################################################################
  396. TASK _Drag(pDescriptor := [target], pHow := 'a', pCoords := {}, pExactFlag := 0)
  397. begin
  398.     try 
  399.     begin
  400.         if(pExactFlag)
  401.         begin
  402.             switch pHow
  403.             begin
  404.                 case 'a':                    # absolute
  405.                     drag pDescriptor a:pCoords!;
  406.                 default:                    # relative
  407.                     drag pDescriptor r:pCoords!;
  408.             end;
  409.         end;
  410.         else
  411.         begin
  412.             switch pHow
  413.             begin
  414.                 case 'a':                    # absolute
  415.                     drag pDescriptor a:pCoords;
  416.                 default:                    # relative
  417.                     drag pDescriptor r:pCoords;
  418.             end;
  419.         end;
  420.     end;
  421.     catch theError
  422.         ExceptionDispatcher(theError,,{"_Drag", {pDescriptor, pHow, pCoords, pExactFlag}});
  423. end;
  424.  
  425. #########################################################################
  426. #                _Size(pTheDesc)
  427. #========================================================================
  428. #    Description:    Error checking prototype for descriptor selecting
  429. #    Parameters:        pWindowDesc:    the window descriptor to select
  430. #                    pHow:    how to size
  431. #                        r - relative
  432. #                        w - width only
  433. #                        h - height only
  434. #                        wh - both width and height
  435. #                    pCoords:  list of coord(s).  Single element list if pHow is
  436. #                              w or h, two element list (width, height) if r or wh.
  437. #    Returns:        0 - couldn't match
  438. #                    1 - successful match
  439. #    Examples:        _Size([window o:1]);
  440. #    Assumptions:    VU 2.1
  441. #========================================================================
  442. #    History:
  443. #    ML    11/15/95    switch on pHow, default to 'wh', rename 1st param,
  444. #                    default to window desc.
  445. #########################################################################
  446. TASK _Size(pWindowDesc := [window o:1], pHow := 'wh', pCoords := {}, pExactFlag := 0)
  447. begin
  448.     try 
  449.     begin
  450.         if(pExactFlag)
  451.         begin
  452.             switch pHow
  453.             begin
  454.                 case 'r':                        # relative
  455.                     size pWindowDesc r:pCoords!;
  456.                 case 'w':                        # only width
  457.                     size pWindowDesc w:pCoords[1]!;
  458.                 case 'h':                        # Only height
  459.                     size pWindowDesc h:pCoords[1]!;
  460.                 default:                        # width and height
  461.                     size pWindowDesc w:pCoords[1] h:pCoords[2]!;
  462.             end;
  463.         end;
  464.         else
  465.         begin
  466.             switch pHow
  467.             begin
  468.                 case 'r':                        # relative
  469.                     size pWindowDesc r:pCoords;
  470.                 case 'w':                        # only width
  471.                     size pWindowDesc w:pCoords[1];
  472.                 case 'h':                        # Only height
  473.                     size pWindowDesc h:pCoords[1];
  474.                 default:                        # width and height
  475.                     size pWindowDesc w:pCoords[1] h:pCoords[2];
  476.             end;
  477.         end;
  478.     end;
  479.     catch theError
  480.         ExceptionDispatcher(theError,,{"_Size", {pWindowDesc, pHow, pCoords, pExactFlag}});
  481. end;
  482.  
  483. #########################################################################
  484. #                _Close(pDescriptor, pExactFlag)
  485. #========================================================================
  486. #    Description:    Error checking prototype for descriptor matching
  487. #    Parameters:        pTheDesc:    the descriptor to match, always looks for exact
  488. #                                (don't include '!')
  489. #    Returns:        0 - couldn't match
  490. #                    1 - successful match
  491. #    Examples:        _Close([window o:1]);
  492. #    Assumptions:    VU 2.1
  493. #========================================================================
  494. #    History:
  495. #########################################################################
  496. TASK _Close(pDescriptor := [], pExactFlag := 0)
  497. begin
  498.     try 
  499.     begin
  500.         if(pExactFlag)
  501.             Close pDescriptor!;
  502.         else
  503.             Close pDescriptor;
  504.     end;
  505.     catch theError
  506.         ExceptionDispatcher(theError,,{"_Close", {pDescriptor, pExactFlag}});
  507. end;
  508.  
  509. #########################################################################
  510. #                _Zoom(pDescriptor, pExactFlag)
  511. #========================================================================
  512. #    Description:    Error checking prototype for descriptor matching
  513. #    Parameters:        pTheDesc:    the descriptor to match, always looks for exact
  514. #                                (don't include '!')
  515. #    Returns:        0 - couldn't match
  516. #                    1 - successful match
  517. #    Examples:        _Zoom([window o:1]);
  518. #    Assumptions:    VU 2.1
  519. #========================================================================
  520. #    History:
  521. #########################################################################
  522. TASK _Zoom(pDescriptor := [], pExactFlag := 0)
  523. begin
  524.     try 
  525.     begin
  526.         if(pExactFlag)
  527.             zoom pDescriptor!;
  528.         else
  529.             zoom pDescriptor;
  530.     end;
  531.     catch theError
  532.         ExceptionDispatcher(theError,,{"_Zoom", {pDescriptor, pExactFlag}});
  533. end;
  534.  
  535. #########################################################################
  536. #                _Scroll(pTheDesc)
  537. #========================================================================
  538. #    Description:    Error checking prototype for descriptor selecting
  539. #    Parameters:        pTheDesc:    the descriptor to select
  540. #    Returns:        0 - couldn't match
  541. #                    1 - successful match
  542. #    Examples:        _Scroll([window o:1]);
  543. #    Assumptions:    VU 2.1
  544. #========================================================================
  545. #    History:
  546. #    ML    12/7/94        Changed pPositions to pCoords in task declaration
  547. #########################################################################
  548. TASK _Scroll(pDescriptor := [target], pHow := 'a', pCoords := {}, pExactFlag := 0)
  549. begin
  550.     try 
  551.     begin
  552.         if(pExactFlag)
  553.         begin
  554.             switch pHow
  555.             begin
  556.                 case 'a':                        # absolute
  557.                     scroll pDescriptor a:pCoords!;
  558.                 default:                        # relative
  559.                     scroll pDescriptor r:pCoords!;
  560.             end;
  561.         end;
  562.         else
  563.         begin
  564.             switch pHow
  565.             begin
  566.                 case 'a':                        # absolute
  567.                     scroll pDescriptor a:pCoords;
  568.                 default:                        # relative
  569.                     scroll pDescriptor r:pCoords;
  570.             end;
  571.         end;
  572.     end;
  573.     catch theError
  574.         ExceptionDispatcher(theError,,{"_Scroll", {pDescriptor, pHow, pCoords, pExactFlag}});
  575. end;
  576.  
  577.  
  578. #########################################################################
  579. #                _Type(pTheDesc)
  580. #========================================================================
  581. #    Description:    Error checking prototype for descriptor selecting
  582. #    Parameters:        pTheDesc:    the descriptor to select
  583. #    Returns:        0 - couldn't match
  584. #                    1 - successful match
  585. #    Examples:        _Scroll([window o:1]);
  586. #    Assumptions:    VU 2.1
  587. #========================================================================
  588. #    History:
  589. #########################################################################
  590. TASK _Type(pKeyList := {}, pCodeList := {}, pPad := 0, pKeyStrokesFirst := 1)
  591. begin
  592.     try 
  593.     begin
  594.         if(pKeyStrokesFirst)
  595.             Type k:pKeyList c:pCodeList p:pPad;
  596.         else
  597.             Type c:pCodeList k:pKeyList p:pPad;
  598.     end;
  599.     catch theError
  600.         ExceptionDispatcher(theError,,{"_Type", {pKeyList, pCodeList, pPad, pKeyStrokesFirst}});
  601. end;
  602.  
  603. #########################################################################
  604. #                _PressKey(pTheDesc)
  605. #========================================================================
  606. #    Description:    Error checking prototype for descriptor selecting
  607. #    Parameters:        pTheDesc:    the descriptor to select
  608. #    Returns:        0 - couldn't match
  609. #                    1 - successful match
  610. #    Examples:        _PressKey([window o:1]);
  611. #    Assumptions:    VU 2.1
  612. #========================================================================
  613. #    History:
  614. #########################################################################
  615. TASK _PressKey(pKeyList := {}, pCodeList := {}, pPad := 0)
  616. begin
  617.     try 
  618.         Presskey k:pKeyList c:pCodeList p:pPad;
  619.     catch theError
  620.         ExceptionDispatcher(theError,,{"_PressKey", {pKeyList, pCodeList, pPad}});
  621. end;
  622. #########################################################################
  623. #                _ReleaseKey(pTheDesc)
  624. #========================================================================
  625. #    Description:    Error checking prototype for descriptor selecting
  626. #    Parameters:        pTheDesc:    the descriptor to select
  627. #    Returns:        0 - couldn't match
  628. #                    1 - successful match
  629. #    Examples:        _ReleaseKey([window o:1]);
  630. #    Assumptions:    VU 2.1
  631. #========================================================================
  632. #    History:
  633. #########################################################################
  634. TASK _ReleaseKey(pKeyList := {}, pCodeList := {}, pPad := 0)
  635. begin
  636.     try 
  637.         ReleaseKey k:pKeyList c:pCodeList p:pPad;
  638.     catch theError
  639.         ExceptionDispatcher(theError,,{"_ReleaseKey", {pKeyList, pCodeList, pPad}});
  640. end;
  641. #########################################################################
  642. #                _Move(pTheDesc)
  643. #========================================================================
  644. #    Description:    Error checking prototype for descriptor selecting
  645. #    Parameters:        pTheDesc:    the descriptor to select
  646. #    Returns:        0 - couldn't match
  647. #                    1 - successful match
  648. #    Examples:        _Move([window o:1]);
  649. #    Assumptions:    VU 2.1
  650. #========================================================================
  651. #    History:
  652. #########################################################################
  653. TASK _Move(pHow := 'a', pCoords := {})
  654. begin
  655.     try 
  656.     begin
  657.         switch pHow
  658.         begin
  659.             case 'a':            # absolute
  660.                 Move a:pCoords;
  661.             default:            # relative
  662.                 Move r:pCoords;
  663.         end;
  664.     end;
  665.     catch theError
  666.         ExceptionDispatcher(theError,,{"_Move", {pHow, pCoords}});
  667. end;
  668. #########################################################################
  669. #                _Click(pTheDesc)
  670. #========================================================================
  671. #    Description:    Error checking prototype for descriptor selecting
  672. #    Parameters:        pTheDesc:    the descriptor to select
  673. #    Returns:        0 - couldn't match
  674. #                    1 - successful match
  675. #    Examples:        _Click([window o:1]);
  676. #    Assumptions:    VU 2.1
  677. #========================================================================
  678. #    History:
  679. #########################################################################
  680. TASK _Click()
  681. begin
  682.     try 
  683.         Click;
  684.     catch theError
  685.         ExceptionDispatcher(theError,,{"_Click"});
  686. end;
  687. #########################################################################
  688. #                _DoubleClick(pTheDesc)
  689. #========================================================================
  690. #    Description:    Error checking prototype for descriptor selecting
  691. #    Parameters:        pTheDesc:    the descriptor to select
  692. #    Returns:        0 - couldn't match
  693. #                    1 - successful match
  694. #    Examples:        _DoubleClick([window o:1]);
  695. #    Assumptions:    VU 2.1
  696. #========================================================================
  697. #    History:
  698. #########################################################################
  699. TASK _DoubleClick()
  700. begin
  701.     try 
  702.         doubleClick;
  703.     catch theError
  704.         ExceptionDispatcher(theError,,{"_DoubleClick"});
  705. end;
  706. #########################################################################
  707. #                _PressMouse(pTheDesc)
  708. #========================================================================
  709. #    Description:    Error checking prototype for descriptor selecting
  710. #    Parameters:        pTheDesc:    the descriptor to select
  711. #    Returns:        0 - couldn't match
  712. #                    1 - successful match
  713. #    Examples:        _PressMouse([window o:1]);
  714. #    Assumptions:    VU 2.1
  715. #========================================================================
  716. #    History:
  717. #########################################################################
  718. TASK _PressMouse()
  719. begin
  720.     try 
  721.         PressMouse;
  722.     catch theError
  723.         ExceptionDispatcher(theError,,{"_PressMouse"});
  724. end;
  725. #########################################################################
  726. #                _ReleaseMouse(pTheDesc)
  727. #========================================================================
  728. #    Description:    Error checking prototype for descriptor selecting
  729. #    Parameters:        pTheDesc:    the descriptor to select
  730. #    Returns:        0 - couldn't match
  731. #                    1 - successful match
  732. #    Examples:        _ReleaseMouse([window o:1]);
  733. #    Assumptions:    VU 2.1
  734. #========================================================================
  735. #    History:
  736. #########################################################################
  737. TASK _ReleaseMouse()
  738. begin
  739.     try 
  740.         ReleaseMouse;
  741.     catch theError
  742.         ExceptionDispatcher(theError,,{"_ReleaseMouse"});
  743. end;
  744. #########################################################################
  745. #                _Launch(pTheDesc)
  746. #========================================================================
  747. #    Description:    Error checking prototype for descriptor selecting
  748. #    Parameters:        pTheDesc:    the descriptor to select
  749. #    Returns:        0 - couldn't match
  750. #                    1 - successful match
  751. #    Examples:        _Launch([window o:1]);
  752. #    Assumptions:    VU 2.1
  753. #========================================================================
  754. #    History:
  755. # MDF    06/17/96    Added pInForeground to parameter.
  756. #########################################################################
  757. TASK _Launch(pApplication := '', pOntarget := TRUE, pInForeground := TRUE)
  758. begin
  759.     try 
  760.         return(Launch(pApplication, pOntarget, pInForeground));
  761.     catch theError
  762.     begin
  763.         ExceptionDispatcher(theError,,{"_Launch", {pApplication, pOntarget, pInForeground}});
  764.         return (0);
  765.     end;
  766. end;
  767.  
  768. #########################################################################
  769. #                _Collect(pDescriptor, pExactFlag)
  770. #========================================================================
  771. #    Description:    Error checking prototype for descriptor matching
  772. #    Parameters:        pTheDesc:    the descriptor to match, always looks for exact
  773. #                                (don't include '!')
  774. #    Returns:        {} - couldn't match
  775. #                    descriptor list - successful match
  776. #    Examples:        _Collect([window o:1]);
  777. #    Assumptions:    VU 2.1
  778. #========================================================================
  779. #    History:
  780. # SBR    02/05/97    Return {} for match fail instead of 0.
  781. #########################################################################
  782. TASK _Collect(pDescriptor := [target], pExactFlag := 0)
  783. begin
  784.     try 
  785.     begin
  786.         if(pExactFlag)
  787.             return(collect pDescriptor!);
  788.         else
  789.             return(collect pDescriptor);
  790.     end;
  791.     catch theError
  792.     begin
  793.         if theError <> -1105
  794.             ExceptionDispatcher(theError,,{"_Collect", {pDescriptor, pExactFlag}});
  795.             
  796.         ###SBR Fixed 01/10/97
  797.         #return (0);
  798.         return {};
  799.         ###SBR Fixed
  800.     end;
  801. end;
  802.  
  803. #########################################################################
  804. #                _Gestalt(pSelector)
  805. #========================================================================
  806. #    Description:    Error checking for gestalt
  807. #    Parameters:        pSelector:    gestalt selector
  808. #    Returns:        0 - unsuccesful gestalt call
  809. #                    {list} - gestalt result
  810. #    Examples:        _Gestalt('sysv');
  811. #    Assumptions:    VU 2.1
  812. #========================================================================
  813. #    History:
  814. #########################################################################
  815. TASK _Gestalt(pSelector)
  816. begin
  817.     try 
  818.         return(gestalt(pSelector));
  819.     catch theError
  820.     begin
  821.         ExceptionDispatcher(theError,,{"_Gestalt", {pSelector}});
  822.         return (0);
  823.     end;
  824. end;
  825.  
  826. #########################################################################
  827. #                _DebugStr(pTheString, pAtSystemTaskTime)
  828. #========================================================================
  829. #    Description:    Invokes our exceptionHandling mechanism for the DebugStr call.
  830. #    Parameters:        pTheString:    debug string e.g. ';ht'
  831. #                    pAtSystemTaskTime - indicate interupt or systemTask time
  832. #    Returns:        nothing
  833. #    Examples:        _DebugStr(';ht;g');
  834. #    Assumptions:    VU 2.1
  835. #========================================================================
  836. #    History:
  837. #########################################################################
  838. TASK _DebugStr(pTheString, pAtSystemTaskTime := false)
  839. begin
  840.     try 
  841.         DebugStr(pTheString, pAtSystemTaskTime);
  842.     catch theError
  843.         ExceptionDispatcher(theError,,{"_DebugStr", {pTheString, pAtSystemTaskTime}});
  844. end;
  845.  
  846.